cmake_minimum_required(VERSION 3.10)

project(ChatServer1 LANGUAGES CXX)


set(PROJECT_NAME ChatServer2)


set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#开启调试功能
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")



#设置boost的根目录
set(BOOST_ROOT "/usr/local/hslDir/mylib/boost")
#引入boost库
find_package(Boost REQUIRED COMPONENTS system thread)

#引入protobuf
find_package(protobuf CONFIG REQUIRED)
#引入gRPC
find_package(gRPC CONFIG REQUIRED)


#引入ChatServer2的源文件
file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc)




#编译ChatServer2
add_executable(${PROJECT_NAME} ChatServer.cc ${SOURCES})




#添加include目录
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/)

#连接boost库
target_link_libraries(${PROJECT_NAME} PRIVATE Boost::system)

#连接grpc和protobuf库
target_link_libraries(${PROJECT_NAME} PRIVATE gRPC::grpc++ gRPC::grpc++_reflection protobuf::libprotobuf)

#引入jsoncpp头文件
target_include_directories(${PROJECT_NAME} PRIVATE /usr/local/include/jsoncpp/)
#引入jsoncpp库
target_link_libraries(${PROJECT_NAME}  PRIVATE /usr/local/lib/libjsoncpp.a)

#引入mysql库
target_link_libraries(${PROJECT_NAME} PRIVATE /usr/lib/x86_64-linux-gnu/libmysqlcppconn.a -lmysqlclient)

#引入hiredis头文件和库
target_include_directories(${PROJECT_NAME} PRIVATE /usr/include/hiredis/)
target_link_libraries(${PROJECT_NAME} PRIVATE /usr/lib/x86_64-linux-gnu/libhiredis.a)